<?php
namespace app\shop\model;

use cubox\Model;

class MemberKey extends Model{
    public function getValue(int  $number_id,string $key):String{

        $row = $this->where('number_id',$number_id)->where('key',$key)->getRow();

        if ($row){
            return $row['value'];
        }else{
            return '';
        }

    }

    public function setValue(int $number_id,string $key,string $value){

        $row =  $this->where('number_id',$number_id)->where('key',$key)->getRow();

        if ($row){
            $this->where('number_id',$number_id)->where('key',$key)->update(['value'=>$value]);
        }else{
            $this->insert(['number_id'=>$number_id,'key'=>$key,'value'=>$value]);
        }

    }

    public function delKey(int $number_id,string $key){
        $this->where('number_id',$number_id)->where('key',$key)->delete();
    }

    
}